var core = require('core');
var util = core.util;
var qr = util.qrcode;
var send = core.send;

var qrcode = function(req, res, next){
    var url = decodeURIComponent(req.query.url);
    var size = parseInt(req.query.size) || 5;
    var img = qr(url, {type: 'png', size: size});
    var SEND = new send(0);
    SEND.docs = {
        qrcode : img
    };
    res.send(SEND);
};

module.exports = qrcode;
